<div class="right_side_operate_area">
    <?php  
        if($showpage==1) {
            if(isset($paging)){ echo $this->renderElement('pagination',$paging);} 
        }
    ?>
    
    <?php $cuser = $session->read('User'); ?>
        <?php if($cuser['isadmin']||$cuser['isgroupadmin']){ ?>
        <div class="right item_add_btn"><?php echo $html->link('添加', 'add');?></div>
    <?php }else{
            echo '<div class="right enableaction">';
            echo "<a>添加</a>";
            echo '</div>';
        }
     ?>
     <div class="right search_box">
        <form onsubmit="return searchuser()">
            <div class="left search_text">
                <?php echo $form->text('User.keyword',array('placeholder'=>'搜索昵称或邮箱','value'=>$keyword, 'id'=>'userkey', 'class'=>'text_box'));?>
            </div>
            <div class="left search_btn"><input type="submit" value=""/></div>
        </form>
        <div class="clear"></div>
    </div>
     <div class="form_sx_drop right">
        <?php 
            $objusertype = classregistry::init('Constant')->UserType;
           // var_dump($objusertype);die;
            echo $form->select('ddlusertype',$objusertype,$usertype, null,null);
        ?>
    </div>
      <?php if($cuser['isadmin']){?>
      <div class="form_sx_drop right">
        <?php 
        	$groups = array(); 
        	$groups['']="请选择模块";
        	foreach ($grouplist as $groupitem){
        		$groups[$groupitem['Group']['id']] = $groupitem['Group']['group_name'];
        	}
            echo $form->select('ddlgroup',$groups,$groupid, null,null);
        ?>
   	 </div>
   	 <?php } ?>
   	 <div class="right_side_title left">
        <div class="right_side_head_line" style="line-height:50px;height:50px">
            <div class="match_condition_desc">
                <span>提示信息：</span>
                <label>系统管理员：<font style="font-size:18px">大号字体</font>；模块管理员：<font color="red">红色字体</font>；</label>
            </div>
        </div>
    </div>
    <div class="clear"></div>
</div>
<div class="right_side_scollbar">
    <div class="detail_info_panel">
        <div class="items_list">
            <table>
                <tr>
                    <th><?php __('Name');?></th>
                    <th><?php __('Email');?></th>
                    
                    <th><?php __("Mobile") ;?></th>
                    <th><?php __("Action") ;?></th>
                </tr>
            <!-- Here is where we loop through our $posts array, printing out post info -->
            <?php 
           // var_dump($users);die;
                foreach ($users as $auser): 
                $trstyle="";
                if( $auser['User']['is_deleted']=="1"){
					$trstyle='text-decoration:line-through';
				}
            ?>
            
                <tr class="per_list" style="<?php echo $trstyle?>">
                    <td>
                    <div class="list_user_name">
                    <div style="float:left;">
                    <span class="user_icon_s">
                    <?php 
                   // var_dump($auser["Attachment"]["file_path"]);die;
                  
                     if($auser['Attachment']['file_path']!="upload/images/"){
                     
               		 	$path=Router::url(array('controller' => '/', 'action' =>''), true);
                     	?>	
               		 <img alt="" src="<?php echo $path;?>showthumbnail.php?path=<?php echo base64_encode($auser['Attachment']['file_path']);?>" />
                	 <?php 
                     }else{  
                        echo $html->image('men_tiny.jpg');
                        } 
                    ?>
                    </span>
                    </div>
                    <?php 
                    $styleadmin="";
                    if($auser['User']['isgroupadmin']){
//						echo '<div class="admin_tag">';
//						echo $html->image("user_admin.png");
//						echo '</div>';
                        $styleadmin="color:red;font-weight:bold;font-size:13px;";
                    }
                    if($auser['User']['isadmin']){
                        $styleadmin.="font-size:18px";
                    }
                    ?>
                    <div style="float:left;">
                    <div>
                    <span><?php 
                    $uupath="/users/view/".$auser['User']['id'];
                        	if($auser['User']['cid']){
                        		$uupath="/companys/showinfo/".$auser['User']['cid'];
                        	}
                    echo $html->link($auser['User']['name'],$uupath,array("style"=>$styleadmin)) ;
                    ?></span>
                    </div>  
                    <div style="float:left;">
                        <span><?php echo $auser['User']['position'].'&nbsp;'; ?></span>
                     
                        <span><?php echo $auser['Group']['group_name']; ?></span>
                        
                      
                    </div>    
                    </div>
                    </td>
                    <td><?php echo $auser['User']['email']; ?></td>
                   
                    <td><?php echo $auser['User']['mobile']; ?></td>
                    <td>
                        <?php 
                        if($cuser['isadmin'] && $auser['User']['cid']!=""){
                        	  echo $html->link("重置密码","/users/initpwd/".$auser['User']['id']);
                        }
                        
                        if($auser['User']['is_deleted']=="1"){
                        	$f = "启用";
                        	echo $html->link($f."账号","/users/setuser/".$auser['User']['id']."/".$auser['User']['is_deleted']);
                        }else if($cuser['isadmin'] && $auser['User']['cid']!=""){
                        	 // echo $html->link("重置密码","/users/initpwd/".$auser['User']['id']);
                        	  $f="禁用";
							  echo $html->link($f."账号","/users/setuser/".$auser['User']['id']."/".$auser['User']['is_deleted']);
                        }
             
                        if($cuser['isadmin']||$cuser['isgroupadmin']  || $cuser['id'] == $auser['User']['id']){
                        	$upath="/users/edit/".$auser['User']['id'];
                        	if($auser['User']['cid']){
                        		$upath="/companys/editinfo/".$auser['User']['cid'];
                        	}
                        		echo $html->link(__('Edit',true),$upath);
                        	}else{
                       			echo "<span class='enableaction'>编辑</span>";
                        }
                        $id = $auser['User']['id'];
                        //$usertype = $auser['User']['usertype'];
                        $email = base64_encode($auser['User']['email']);
                        if($cuser['isadmin']||$cuser['isgroupadmin']){
                       		 echo $html->link(__('Delete',true),"/users/delete/".$id."/".$usertype."/".$email, array("onclick"=>"return doaction(this)")); 
                        }else{
                       		 echo "<span class='enableaction'>删除</span>";
                        }
                        ?> 
                        
                    </td>
                </tr>
            <?php 
                endforeach; 
            ?>
            </table>
        </div>
    </div>
</div>
<?php echo $this->element('actionconfirm',array("title"=>"删除提示","message"=>"你确定要删除吗？")) ?>
<script>
$(document).ready(function() {
    $("#ddlusertype").change(function() { 
        searchuser();
    });
    $("#ddlgroup").change(function() { 
        searchuser();
    });
});
if($("#userkey").val()!=""){
    $("#userkey").focus();
}
function searchuser()
{
    var webpath=$("#getpath").attr('href');
    var urlpath=webpath+"users/index?seach=all";
    var usertype=$("#ddlusertype").val();
    var userkey=$("#userkey").val();
    var groupkey;
    if(idisexist("ddlgroup")){ 
    	groupkey=$("#ddlgroup").val();
    }else{
		groupkey="";
        }
    
    
    if(usertype=="" && userkey=="" &&groupkey==""){
        location.href=urlpath;
    }else{
        if(usertype!=""){
            urlpath+="&usertype="+usertype;
        }
        if(userkey.trim()!=""){
            urlpath+="&keyword="+encodeURIComponent(userkey.trim());
        }
        if(groupkey!=""){
        	urlpath+="&groupid="+groupkey;
        }
        location.href=urlpath;
    }
    return false;
}
funPlaceholder(document.getElementById("userkey"));

function idisexist(id){
    var s=document.getElementById(id);
      if(s){
            return true;   
           }else{
			return false;
           }
   } 
</script>